﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace PROJECT_BOMBER.BLL
{
    public static class Controler
    {

        #region Variable Etat Button + Fullscreen

        //private static bool activeY = true;
        //private static bool activeX = true;
        //private static bool activeA = true;
        //private static bool activeB = true;
        //private static bool activeStart = true;
        //private static bool fullscreen = false;

        #endregion

        public static void Actions(Character element1, PlayerIndex player, Game game, GraphicsDeviceManager graphics, Camera2d cam)
        {
            /*
            #region Button [Back] => Exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                game.Exit();
            }
            #endregion

            #region Stick Right => X : Rotation, Y : Zoom

            if (GamePad.GetState(player).ThumbSticks.Right.X > 0.7 || GamePad.GetState(player).ThumbSticks.Right.X < -0.7)
            {
                if (cam.Rotation + GamePad.GetState(player).ThumbSticks.Right.X / 200 >= -1 && cam.Zoom + GamePad.GetState(player).ThumbSticks.Right.X / 200 < 1)
                {
                    cam.Rotation += GamePad.GetState(player).ThumbSticks.Right.X / 200;
                }
            }

            if (GamePad.GetState(player).ThumbSticks.Right.Y > 0.2 || GamePad.GetState(player).ThumbSticks.Right.Y < -0.2)
            {
                if (cam.Zoom + GamePad.GetState(player).ThumbSticks.Right.Y / 200 >= 0.28 && cam.Zoom + GamePad.GetState(player).ThumbSticks.Right.Y / 200 < 1)
                {
                    cam.Zoom += GamePad.GetState(player).ThumbSticks.Right.Y / 200;
                }
            }
            #endregion

            #region Stixk Left => X : Speed X
            if (GamePad.GetState(player).ThumbSticks.Left.X > 0.2 || GamePad.GetState(player).ThumbSticks.Left.X < -0.2)
            {
                element1.Speed.X = 
                    GamePad.GetState(player).ThumbSticks.Left.X * element1.Speedmin.X *2
                    + element1.Speedmin.X * 2 * GamePad.GetState(player).Triggers.Right * GamePad.GetState(player).ThumbSticks.Left.X 
                    - (element1.Speedmin.X - element1.Speedmin.X / 100) * GamePad.GetState(player).Triggers.Left * GamePad.GetState(player).ThumbSticks.Left.X;

                if (element1.Attack)
                {
                    element1.Speed.X = GamePad.GetState(player).ThumbSticks.Left.X * element1.Speedmin.X * 8;
                }
            }
            #endregion

            #region Button [Y] => active/desactive Fly
            if (GamePad.GetState(player).Buttons.Y == ButtonState.Pressed && activeY && element1.Speed.Y < 0)
            { 
                element1.Fly = !element1.Fly;
                activeY = false;
            }
            else if (GamePad.GetState(player).Buttons.Y == ButtonState.Pressed && activeY)
            {
                element1.Fly = false;
            }

            if (GamePad.GetState(player).Buttons.Y == ButtonState.Released)
            {
                activeY = true;
            }
            #endregion

            #region Button [A] => Jump & Double Jump
            if (GamePad.GetState(player).Buttons.A == ButtonState.Pressed && ((!element1.Dbjump && !element1.Onground) || (!element1.Jump && element1.Onground)) && activeA)
            {
                element1.Speed.Y = -element1.Speedmax.Y/7;
                element1.Onground = false;

                if (!element1.Dbjump)
                {
                    element1.Dbjump = true;
                }

                if (!element1.Jump)
                {
                    element1.Dbjump = false;
                }
               
                element1.Jump = true;
                activeA = false;
            }

            if (GamePad.GetState(player).Buttons.A == ButtonState.Released && !element1.Onground)
            {
                activeA = true;
            }


            if (GamePad.GetState(player).Buttons.A == ButtonState.Released && element1.Onground)
            {
                activeA = true;
                element1.Jump = false;
                element1.Dbjump = true;

            }
            #endregion

            #region Button [B] => Attack
            if (GamePad.GetState(player).Buttons.B == ButtonState.Pressed && element1.Speed.X != 0 && !element1.Fly)
            {
                element1.Attack = true;
            }
            else
            {
                element1.Attack = false;
            }
            #endregion

            #region Button [X] => {debug} Allow Speed Y
            if (GamePad.GetState(player).Buttons.X == ButtonState.Pressed)
            {
                element1.Speed.Y = -GamePad.GetState(player).ThumbSticks.Left.Y * element1.Speedmin.Y * 5;
            }
            #endregion

            #region Button [Start] => Fullscreen
            if (!fullscreen && GamePad.GetState(player).Buttons.Start == ButtonState.Pressed && activeStart)
            {
                graphics.PreferredBackBufferWidth = 1600;
                graphics.PreferredBackBufferHeight = 900;
                graphics.ToggleFullScreen();
                activeStart = false;
                fullscreen = !fullscreen; 
            }
            else if (GamePad.GetState(player).Buttons.Start == ButtonState.Pressed && activeStart)
            {
                graphics.PreferredBackBufferWidth = 1600-(160*3);
                graphics.PreferredBackBufferHeight = 900-(90*3);
                graphics.ToggleFullScreen();
                activeStart = false;
                fullscreen = !fullscreen; 
            }
            if (GamePad.GetState(player).Buttons.Start == ButtonState.Released)
            {
                activeStart = true;
            }
            #endregion
            */

        } 
           
    }
}
